home *** CD-ROM | disk | FTP | other *** search
- Path: math.ohio-state.edu!usenet
- From: Chris Mongold <cmongold@magnus.acs.ohio-state.edu>
- Newsgroups: comp.lang.c
- Subject: sscanf problems
- Date: 24 Jan 1996 04:20:47 GMT
- Organization: The Ohio State University, Department of Mathematics
- Message-ID: <4e4c2v$j2g@mathserv.mps.ohio-state.edu>
- NNTP-Posting-Host: ts33-10.homenet.ohio-state.edu
-
- Hello,
- I'm sorry if this is an inappropriate topic, but I've tried
- everything else. I can't seem to get sscanf to to separate a string
- into various variable types. Here is an example:
-
- #include <stdio.h>
-
- void main()
- {
- char input[20], crap[17], segment[6], seg_len[3], begin[3], load[3];
- int type;
- FILE *fp;
-
- printf("File: ");
- gets(input);
-
- fp = fopen(input, "r");
-
- while(!feof(fp))
- {
- fgets(crap, 17, fp);
- sscanf(crap, "%d%3s%6s%3s%3s", type, begin, segment, seg_len, load);
- printf("%d %3s %6s %3s %3s", type, begin, segment, seg_len, load);
-
- }
- }
- No matter what I do, it always 'bus errors' when I sscanf. I've tried
- it several different ways, including making crap larger, but to
- no avail. If anyone can help me, I would greatly appreciate it.
- Please respond to cmongold@magnus.acs.ohio-state.edu
-
- Thanks,
-
- Chris
-